import { instance } from "../utils/request";
const getGoodsPagination = async (
  page: number,
  limit: number,
  key?: string,
  sid?: number,
  gtid?: number,
  isShelve?: number
) => {
  return await instance.get("/Goods/Pagination", {
    page,
    limit,
    key,
    sid,
    gtid,
    isShelve,
  });
};

const addGoods = async (data: RequestCreateGoodsDto) => {
  return await instance.post("/Goods/Add", data);
};

const updateGoods = async (data: RequestUpdateGoodsDto) => {
  return await instance.post("/Goods/Update", data);
};

const getGoodsDetail = async (id: number) => {
  return await instance.get("/Goods/Detail", { id });
};

const getGoodTypeCount = async () => {
  return await instance.get("/Goods/GetGoodTypeCount");
};

const deleteGoods = async (data: RequestIdGoodsDto) => {
  return await instance.post("/Goods/Delete", data);
};

const setGoodIsShelve = async (id: number, isShelve: number) => {
  return await instance.post("Goods/SetIsShelve", { id, isShelve });
};

const setGoodTopLevel = async (id: number, topLevel: number) => {
  return await instance.post("Goods/SetTopLevel", { id, topLevel });
};

const replenishment = async (id: number, count: number) => {
  return await instance.post("Goods/Replenishment", { id, count });
};

const GoodsApi = {
  getGoodsPagination,
  addGoods,
  updateGoods,
  getGoodsDetail,
  deleteGoods,
  getGoodTypeCount,
  setGoodIsShelve,
  setGoodTopLevel,
  replenishment,
};

export default GoodsApi;
